<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>

</body>
</html>

<script>

    let functor = function (_arr) {
      let arr = _arr;
      let map = function (f) {
        let rt_arr = [];
        for (let item of arr) {
          rt_arr.push(f(item));
        }
        return rt_arr;
      };
      return {
        map: map
      }
    };

    let test_arr = [1, 2, 3, 4, 5];
    let arr_function = function (n) {
      return n * 2;
    };
    let rs = functor(test_arr).map(function (item) {
      return arr_function(item);
    });

    console.log(rs);



</script>